﻿using System.Reflection;

namespace Borg
{
    public class PlugEventArgs : SystemEventArgs
    {
        internal readonly SlotInfo slotInfo;
        internal readonly PlugInfo plugInfo;

        public SlotInfo SlotInfo
        {
            get { return slotInfo; }
        }

        public PlugInfo PlugInfo
        {
            get { return plugInfo; }
        }

        public object Extension
        {
            get { return plugInfo.extensionInfo.Object; }
        }

        public PlugEventArgs(SlotInfo slotInfo, PlugInfo plugInfo, Assembly initiator)
            : base(initiator)
        {
            this.slotInfo = slotInfo;
            this.plugInfo = plugInfo;
        }

        public T GetExtension<T>()
        {
            return (T)Extension;
        }

        public T GetParamValue<T>(string name)
        {
            return (T)GetParamValue(name);
        }

        public object GetParamValue(string name)
        {
            return plugInfo.plugTypeInfo.GetParamValue(name);
        }
    }

    public delegate void PlugEventHandler(object sender, PlugEventArgs args);
}

